#include <cstring>
#include <iostream>

using namespace std;

const int N = 30;

int n, m;
char g[N][N];
bool st[N][N];

int dfs(int x, int y) {
    int res = 1;
    st[x][y] = true;
    
    int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
    for (int i = 0; i < 4; ++ i) {
        int a = x + dx[i], b = y + dy[i];
        if (a >= 0 && a < n && b >= 0 && b < m && !st[a][b] && g[a][b] == '.') res += dfs(a, b); 
    }
    
    return res;
}

int main() {
    while (cin >> m >> n, n) {
        memset(st, 0, sizeof st);
        for (int i = 0; i < n; ++ i) scanf("%s", g[i]);
        
        bool flag = 0;
        for (int i = 0; i < n; ++ i) {
            if (flag) break;
            
            for (int j = 0; j < m; ++ j) {
                if (flag) break;
                
                if (g[i][j] == '@') {
                    printf("%d\n", dfs(i, j));
                    flag = 1;
                }
            }
        }
    }
    
    return 0;
}